package cn.yl.caner.dao;

import java.sql.Connection;
import java.sql.SQLException;
import javax.sql.DataSource;

import org.apache.commons.dbutils.QueryRunner;

import cn.yl.caner.domain.RegisteData;
import cn.yl.caner.utils.DataSourceUtils;
import cn.yl.caner.utils.MyDataSourceUtils;

public class RegisteDao {
	
	public int registeAccount(RegisteData registedata) throws SQLException{
	
		//把注册信息写入数据库
		Connection con = MyDataSourceUtils.getCurrentConnection();
		DataSource c = DataSourceUtils.getDataSource();
		QueryRunner qr = new QueryRunner(c);
		String sql = "insert into account(id,username,password,email,phone) values(?,?,?,?,?)";
		int i = qr.update(con,sql,registedata.getId(),registedata.getUsername(),registedata.getPassword(),
				registedata.getEmail(),registedata.getPhone());
		//状态码
		if(i == 0) {
			return 0;
		}else {
			return 1;
		}
	}
}

